home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / wais / waisgate / HTList.h < prev    next >
C/C++ Source or Header  |  1995-05-09  |  2KB  |  60 lines

  1. /*  */
  2.  
  3. /*              List object
  4. **
  5. **      The list object is a generic container for storing collections
  6. **      of things in order.
  7. */
  8. #ifndef HTLIST_H
  9. #define HTLIST_H
  10.  
  11. #include "HTUtils.h"  /* for BOOL type and PARAMS and ARGS*/
  12.  
  13. typedef struct _HTList HTList;
  14.  
  15. struct _HTList {
  16.   void * object;
  17.   HTList * next;
  18. };
  19.  
  20. #ifdef SHORT_NAMES
  21. #define HTList_new                      HTLiNew
  22. #define HTList_delete                   HTLiDele
  23. #define HTList_addObject                HTLiAdOb
  24. #define HTList_removeObject             HTLiReOb
  25. #define HTList_removeLastObject         HTLiReLa
  26. #define HTList_removeFirstObject        HTLiReFi
  27. #define HTList_count                    HTLiCoun
  28. #define HTList_indexOf                  HTLiInOf
  29. #define HTList_objectAt                 HTLiObAt
  30. #endif
  31.  
  32. extern HTList * HTList_new NOPARAMS;
  33. extern void     HTList_delete PARAMS((HTList *me));
  34.  
  35. /*      Add object to START of list
  36. */
  37. extern void     HTList_addObject PARAMS((HTList *me, void *newObject));
  38.  
  39.  
  40. extern BOOL     HTList_removeObject PARAMS((HTList *me, void *oldObject));
  41. extern void *   HTList_removeLastObject PARAMS((HTList *me));
  42. extern void *   HTList_removeFirstObject PARAMS((HTList *me));
  43. #define         HTList_isEmpty(me) (me ? me->next == NULL : YES)
  44. extern int      HTList_count PARAMS((HTList *me));
  45. extern int      HTList_indexOf PARAMS((HTList *me, void *object));
  46. #define         HTList_lastObject(me) \
  47.   (me && me->next ? me->next->object : NULL)
  48. extern void *   HTList_objectAt PARAMS((HTList *me, int position));
  49.  
  50. /* Fast macro to traverse the list. Call it first with copy of list header :
  51.    it returns the first object and increments the passed list pointer.
  52.    Call it with the same variable until it returns NULL. */
  53. #define HTList_nextObject(me) \
  54.   (me && (me = me->next) ? me->object : NULL)
  55.  
  56. #endif /* HTLIST_H */
  57. /*
  58.  
  59.     */
  60.